package com.xc.sort;

import java.io.Serializable;
import java.util.Arrays;

public class QuickDemo implements Serializable {

    private static final long serialVersionUID = 774644421731759687L;

    public static void main(String[] args) throws Exception {

//        int arr[]={1, 88, 2, 0, -999,12,-9,1000,7};
//        int arr[]={6, 1 ,2 ,7 ,9 ,3, 4, 5, 10, 8};
//        6 1 2 5 9 3 4 7 10 8
        int arr[]={6, 7 ,2,3,4,8};
        quickdemo(arr,0,arr.length-1);
        quickdemo1(arr,0,arr.length-1);

        System.out.println(Arrays.toString(arr));
    }


    public  static  void quickdemo(int arr[],int left,int right){

        if(left>right)return;

        //选择基准
        int temp=arr[left];
        int t;
        int l = left;//左
        int r = right;//右边
        while (l<r){//左右相遇结束

            while (temp<=arr[r]&&l<r){
                r--;//r=7 6

                //r=4 3
            }
            while (temp>=arr[l]&&l<r){
                l++;//l=3 4
                //l=1
            }
            //如果满足条件交换
             if (l<r){
                 t=arr[r];
                 arr[r]=arr[l];
                 arr[l]=t;

             }


        }
        //基准交换
        arr[left]=arr[r];
        arr[l]=temp;
        //递归调用左半数组
        quickdemo(arr, left, r-1);
        //递归调用右半数组
        quickdemo(arr, r+1, right);


    }




    public static void  quickdemo1(int arr[],int i,int j){

            if (i>j)return;

            //选择基准   因为基准会变


    }


}
